<html>
<head><meta charset="utf-8"><title>running tests · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html">running tests</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="190375597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375597">(Mar 12 2020 at 10:41)</a>:</h4>
<p>Hey, I'm trying to adopt vscode+rust-analyzer instead of my beloved emacs for some chalk hacking. I have a kind of silly question. How do I run tests? I can go to the Terminal and do <code>cargo test --all</code> but I was hoping there is some more "integrated" way for me to do this. (Chalk's tests in particular are mostly in a <code>test</code> directory.)</p>



<a name="190375652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375652">(Mar 12 2020 at 10:42)</a>:</h4>
<p>In any case is there a way to run cargo test via some shortcut or something?</p>



<a name="190375666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375666">(Mar 12 2020 at 10:42)</a>:</h4>
<p>Ah, I <em>do</em> see a "run test" popup highlighted over <code>#[test]</code> functions</p>



<a name="190375738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375738">(Mar 12 2020 at 10:42)</a>:</h4>
<p>I guess that will do</p>



<a name="190375903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375903">(Mar 12 2020 at 10:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I'd recommend using <a href="https://marketplace.visualstudio.com/items?itemName=hdevalke.rust-test-lens" target="_blank" title="https://marketplace.visualstudio.com/items?itemName=hdevalke.rust-test-lens">this extension</a> to run a test in a debugger. There is some work on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3539" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/3539">merging this</a> functionality to rust-analyzer. Beware that you also need <a href="https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb" target="_blank" title="https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb"><code>vscode-lldb</code></a> debug adapter extension to make it happen.</p>



<a name="190375993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190375993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190375993">(Mar 12 2020 at 10:46)</a>:</h4>
<p>interesting</p>



<a name="190376407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190376407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190376407">(Mar 12 2020 at 10:52)</a>:</h4>
<p>Side note that powershell doesn't seem to support <code>FOO=BAR</code> notation for setting environment variables for a single command; that's annoying</p>



<a name="190376676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190376676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190376676">(Mar 12 2020 at 10:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I generally use <code>Rust Analyzer: Run</code> which runs a single test/single test module at the cursor. It doesn't have a shortctut by default, but it's a good idea to assign one</p>



<a name="190376690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190376690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190376690">(Mar 12 2020 at 10:57)</a>:</h4>
<p><a href="/user_uploads/4715/tcc1_Tk75QQOEhul5-w67uVD/run-tests.gif" target="_blank" title="run-tests.gif">run-tests.gif</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/tcc1_Tk75QQOEhul5-w67uVD/run-tests.gif" target="_blank" title="run-tests.gif"><img src="/user_uploads/4715/tcc1_Tk75QQOEhul5-w67uVD/run-tests.gif"></a></div>



<a name="190376776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190376776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190376776">(Mar 12 2020 at 10:58)</a>:</h4>
<p><a href="/user_uploads/4715/NSRCSgx0f0rWXv0FDILCsPrJ/run.gif" target="_blank" title="run.gif">run.gif</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/NSRCSgx0f0rWXv0FDILCsPrJ/run.gif" target="_blank" title="run.gif"><img src="/user_uploads/4715/NSRCSgx0f0rWXv0FDILCsPrJ/run.gif"></a></div>



<a name="190376910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190376910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190376910">(Mar 12 2020 at 11:00)</a>:</h4>
<p>For running the whole test suite, I just run <code>cargo qt</code> in an external terminal. </p>
<p>I'd love to add an ability to run a cargo command with completion for arguments (which would be smarter than bash completion, b/c it can suggest packages for -p argument). This feature is implemented in IntelliJ, but VS Code I think lacks the necessary UI for it.</p>



<a name="190377015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190377015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190377015">(Mar 12 2020 at 11:01)</a>:</h4>
<p>Also note that <code>Rust Analyzer: Run</code> remembers the last test you've run. So my typical workflow is:</p>
<ol>
<li>Using worksapce symbol/document symbol go to the interesting test</li>
<li>Run it once with a shortcut</li>
<li>Go back to hacking on the code, re-runing this single test with a shortcut</li>
</ol>



<a name="190377740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190377740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190377740">(Mar 12 2020 at 11:11)</a>:</h4>
<p>Coincidentally, the bot just said that the request for "command with completion for arguments" goes to vscode backlog: <a href="https://github.com/microsoft/vscode/issues/35785#issuecomment-478551918" target="_blank" title="https://github.com/microsoft/vscode/issues/35785#issuecomment-478551918">https://github.com/microsoft/vscode/issues/35785#issuecomment-478551918</a> :)</p>



<a name="190378175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190378175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190378175">(Mar 12 2020 at 11:17)</a>:</h4>
<p>It actually said the issue hasn't received enough upvotes yet. There are 10 more days to upvote.</p>



<a name="190384516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190384516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190384516">(Mar 12 2020 at 12:42)</a>:</h4>
<p>I think we're already able to create something like this in VS Code:</p>
<p><a href="/user_uploads/4715/tg0UPuenLqOa2RLy1cC3ChLk/image.png" target="_blank" title="image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/tg0UPuenLqOa2RLy1cC3ChLk/image.png" target="_blank" title="image.png"><img src="/user_uploads/4715/tg0UPuenLqOa2RLy1cC3ChLk/image.png"></a></div><p>React on the input text change, propose the autocompleted options below, remember the input to be able to rerun the action with it (I think the last item is done by VS Code automatically)</p>
<p>I sometimes miss the possibility to constantly rerun the <code>cargo check --all-targets</code> or <code>cargo clippy</code> while iteratively fixing all the issues that pop up.<br>
If I'm not mistaken, RA will also be able to parse this output to highlight the problems and provide the assists.</p>



<a name="190384595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190384595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190384595">(Mar 12 2020 at 12:43)</a>:</h4>
<p>(the screenshot is the <code>Run Cargo Command</code> Action provided by intellij-rust)</p>



<a name="190386624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/running%20tests/near/190386624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/running.20tests.html#190386624">(Mar 12 2020 at 13:04)</a>:</h4>
<p><span class="user-mention" data-user-id="231447">@Kirill Bulatov</span>  The guy that created the issue referenced by matklad said:</p>
<blockquote>
<p>There's also the quick picker, but as far as I know, it doesn't allow you to dynamically update the available options depending on what has been typed in.</p>
</blockquote>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>